﻿using System;


class ParseAnURL
{
    static void Main()
    {
        string text = "Write a program that parses an URL address given in the format:" +
        "and extracts from it the [protocol], [server] and [resource] elements." + 
        "For example from the URL http://www.devbg.org/forum/index.php the following information should be extracted";
        int protocolIndex = text.IndexOf("http");
        int serverIndex = text.IndexOf("//");
        int resourceIndex = text.IndexOf("/",serverIndex + 2);
        int spaceIndex = text.IndexOf(" ",resourceIndex);
        string protocol = text.Substring(protocolIndex,serverIndex - protocolIndex-1);
        string server = text.Substring(serverIndex + 2, resourceIndex - serverIndex - 2);
        string resource = text.Substring(resourceIndex, spaceIndex - resourceIndex);
        Console.WriteLine("[protocol] = {0}",protocol);
        Console.WriteLine("[server] = {0}",server);
        Console.WriteLine("[resource] = {0}",resource);
    }
}

